<?php
session_start();	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外卖网-订单</title>
<link href="style/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> 
<script src="js/jquery.blockUI.js" type="text/javascript"></script>
<script type="text/javascript"> 
$(function(){ 
//Default Action 
$(".tab_content").hide(); //Hide all content 
$("ul.tabs li:first").addClass("active").show(); //Activate first tab 
$(".tab_content:first").show(); //Show first tab content 
//On Click Event 
$("ul.tabs li").click(function() { 
$("ul.tabs li").removeClass("active"); //Remove any "active" class 
$(this).addClass("active"); //Add "active" class to selected tab 
$(".tab_content").hide(); //Hide all tab content 
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
$(activeTab).fadeIn(); //Fade in the active content 
return false; 
}); 
}); 
</script> 
<script type="text/javascript"> 
$(function(){
$('#login').click(function(){   //给box_btn绑定一个鼠标点击的事件
$.blockUI({    //当点击事件发生时调用弹出层
  message: $('#loginbox'),    //要弹出的元素box
  css: {    //弹出元素的CSS属性
    border:'5px solid #334343',
    textAlign: 'left',
	width: '490px',
	top:  ($(window).height() - 290) /2 + 'px', 
    left: ($(window).width() - 490) /2 + 'px', 
	cursor: 'auto'
       },
  overlayCSS: {
	opacity: '0.7' 
	          }
         });
$('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
$('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层

});

$('#shoplogin').click(function(){   //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
    width: '490px',
    top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
    cursor: 'auto'
         },
    overlayCSS: {
    opacity: '0.7' 
              }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层
  $("#alllogin").attr("action","login-shop.php");
  });

});

function editThisByid(thisid){
$("#haveid").val(thisid);
$("#address").val($("#address"+thisid).html());
$("#mobile").val($("#mobile"+thisid).html());
$("#consignee").val($("#consignee"+thisid).html());
$("#phone").val($("#phone"+thisid).html());

}

function RegCheck(RegForm)
{
  if (RegForm.address.value == "")
  {
    alert("请输入详细地址!");
    RegForm.address.focus();
    return (false);
  }

/*var re=/^[\w\x80-\xff]{3,15}$/;
  if(!re.test(RegForm.username.value) ){
    alert("错误：用户名不符合规定。3-15个字符，一个汉字为两个字符");
    RegForm.username.focus();
    return (false);
  }*/
  
  /*if (RegForm.password1.value == "")
  {
    alert("请输入密码!");
    RegForm.password1.focus();
    return (false);
  }*/
  if(RegForm.address.value.length < 6){
    alert("错误：详细地址长度不符合规定。最少6个字符");
    RegForm.address.focus();
    return (false);
  }
 
/*
  if (RegForm.password2.value == "")
  {
    alert("请输入密码!");
    RegForm.password2.focus();
    return (false);
  }
  if (RegForm.password2.value != RegForm.password1.value)
  {
    alert("请确认输入密码一致!");
    RegForm.password1.focus();
    RegForm.password2.focus();
    return (false);
  }*/
  var me= /^1[3|4|5|8][0-9]\d{4,8}$/  ;
  if (!me.test(RegForm.mobile.value))
  {
    alert("请确认手机号码!");
    RegForm.mobile.focus();
    return (false);
  }else
   if(RegForm.consignee.value==""){
    alert("请输入收货人姓名!");
    RegForm.consignee.focus();
    return (false);

  }

}




</script> 
<?php
include('system/db/conn.php');
?>
</head>

<body>

<div id="loginbox" style="display:none">
  <div class="login_title">会员登录</div>
  <div class="login_input">
    <div class="input"><span>账号：</span><span><input name="user" type="text" /></span></div>
    <div class="input"><span>密码：</span><span><input name="pwd" type="password" /></span></div>
    <div class="login_input_1 clearfix"><input name="" type="checkbox" value="" id="store1" /><label for="store1">自动登录</label><a href="#">找回密码</a></div>
    <div class="reg clearfix"><span><input class="login_btn" name="" type="image" src="images/login.jpg" /></span><span>还没有账号？</span><a href="#">立即注册</a></div>
  </div>
</div>

<div class="top">
  <div class="top_content clearfix"><span class="left"><a href="index.php"><img src="images/wmwlogo.png"></a></span><span class="right">
 
  <?php
    if(isset($_SESSION['username'])){
      if($_SESSION['logintype']=="userlog"){
     echo '<a href="member.php">'.$_SESSION['username'],'欢迎你！</a>';
}elseif ($_SESSION['logintype']=="supplierlog") {
   echo '<a href="shop-xx.php">'.$_SESSION['username'],'欢迎你！</a>';
}
      echo '<a href="login.php?action=logout">登出</a>';
    }else{
      echo ' <a href="#" id="login">';
      echo '登录';
      echo '</a> / <a href="reg11.php">注册</a>';
    }
  ?>
  <?php  
      if(!isset($_SESSION['username'])  ){
   ?>
  | <a href="#"  id="shoplogin">店铺登录</a></span></div>
  <?php 
    }

   ?>
</div> 

<div class="content clearfix">
  <div class="content_con clearfix">
    <div class="box_left left">
      <div class="box">
        <div class="box_title"><div class="box_title_con left">
            <?php
              echo $_SESSION['username'];
            ?></div><?php
            if($_SESSION['userlevel']==0){

            ?>
            <div class="lv1 left">
              <?php

                }else{
              ?>
        <div class="lv<?php echo $_SESSION['userlevel'] ?> left">
<?php 
  }
?></div></div>
        <ul class="clearfix box_ul">
          <li><span class="ico2"><a href="member.php">我的订单</a></span></li>
           <li ><span class="ico8"><a href="member-dd.php">订单明细</a></span></li>
          <li class="liselect"><span class="ico3select"><a href="member-add.php">我的地址</a></span></li>
          <li><span class="ico4"><a href="member-edpass.php">修改密码</a></span></li>
        </ul>
      </div>
    </div>
    <div class="box_right right">
      <div class="box" style="height:600px;">
        <div class="box_title"><div class="box_title_title">我的地址</div></div>
        <div class="box_content">
          <div class="box_addr">已经保存的送餐地址</div>
          <div class="box_addr_con">
            <div class="box_addr_con_tit clearfix"><span class="con_1">地址</span><span class="con_5">收货人</span><span class="con_2">联系电话</span><span class="con_3">备选电话</span><span class="con_4">操作</span></div>
            <ul class="box_addr_con_list">
               <?php
            date_default_timezone_set("Asia/Shanghai");
          $area_query = mysql_query("select * from do_user_consignee where user_id=".$_SESSION['userid']);
          while($row = mysql_fetch_array($area_query)){
            echo "<li><span id='address".$row['id']."' class='con_1'>";
            echo $row['address'];
            echo "</span><span id='consignee".$row['id']."' class='con_5'>";
            echo $row['consignee'];
            echo "</span><span id='mobile".$row['id']."' class='con_2'>";
            echo $row['mobile'];
            echo "</span><span id='phone".$row['id']."' class='con_3'>";
            if(is_null($row['phone'])||$row['phone']==""){
              echo "无备选电话";
            }else{
            echo $row['phone'];
            }
            echo "</span><span class='con_4'>";
            if($row['isdefult']=="0"){ 
               echo "<a href='memberAjax.php?function=0&id=".$row['id']."'>设为默认</a> ";

            }elseif ($row['isdefult']=="1") {
             echo "默认地址 ";
            }
           

            echo "| <a  href='javascript:editThisByid(".$row['id'].")' id='edit'>编辑</a> | <a href='memberAjax.php?function=2&id=".$row['id']."'>删除</a></span></li>";
          }
          mysql_free_result($area_query);
        ?>











            </ul>
          </div>
          <div class="box_addr">新增/编辑送餐地址</div>
          <form action="member-address.php" method="post" onsubmit="return RegCheck(this)">
          <input type="hidden" name="haveid" id="haveid" />
          <div class="input_list clearfix" style="margin-top:20px;">
            <div class="tit1"><span class="red">* </span>详细地址</div>
            <div class="left"><input type="text" name="address" id="address"></div>
            <span class="text_note left">请填详细一点</span>
          </div>
          <div class="input_list clearfix">
            <div class="tit1"><span class="red">* </span>联系电话</div>
            <div class="left"><input type="text" name="mobile" id="mobile"></div>
            <span class="text_note left">外卖到时将以该电话通知您</span>
          </div>
           <div class="input_list clearfix">
            <div class="tit1"><span class="red">* </span>收货人&nbsp;&nbsp;</div>
            <div class="left"><input type="text" name="consignee" id="consignee" value=""></div>
            <span class="text_note left">便于送货联系</span>
          </div>
          <div class="input_list clearfix">
            <div class="tit1">备选电话</div>
            <div class="left"><input type="text" name="phone" id="phone"></div>
            <span class="text_note left">为方便送餐员联系，请再留一个备用电话</span>
          </div>
          <div class="save_btn clearfix">
            <input type="image" name="submit" src="images/save.jpg">
          </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<?php include('bottom.php') ?>
</body>
</html>
